var express = require('express');
var router = express.Router();
var userModel = require('../../models/user/user');

//定义路由，当访问该路由的时候，去数据库查找信息并返回
router.post('/', function (req, res, next) {
    var params = req.body
    userModel.find({ openid: params.openid }, function (err, docs) {
        if (docs.length !== 0) {
            let profile = docs[0].profilePic
            docs[0].profilePic = `http://localhost:3000/images/profile-pic/${profile}`
            res.json({ data: docs, msg: '返回成功！', code: 200 })
        }
        else {
            res.json({ data: null, msg: '没有该用户的信息', code: 200 })
        }
    })
})

module.exports = router;
